package com.chenqi.service.impl;

import com.chenqi.dao.TipMapper;
import com.chenqi.model.entity.Tip;
import com.chenqi.service.TipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @description: tip业务实现类
 * @program: ardaicommunity
 * @author: ChenQi
 * @create: 2021-03-2021/3/7-14-56
 */
@Slf4j
@Service
@Transactional(rollbackFor = {Exception.class})
public class TipServiceImpl implements TipService {

    @Autowired
    private TipMapper tipMapper;

    /**
     * 随机获取名言
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public Tip getTodayTip() {
        Tip todayTip = new Tip();
        try{
            todayTip = tipMapper.getTodayTip();
        }catch (Exception e){
            log.error(e.getMessage());
        }
        return todayTip;
    }
}
